package com.phrp.controller;

import com.phrp.service.DictionaryService;
import com.phrp.util.returnResult.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ssc
 * @since 2024-04-27
 */
@RestController
@RequestMapping("/dictionary")
public class DictionaryController {

    @Autowired
    private DictionaryService dictionaryService;

    /**
     * 获取字典表中的用户类型
     * @param tableName
     * @param fieldName
     * @return
     */
    @GetMapping(value = "getUserType")
    public ResponseResult getUserType(@RequestParam String tableName,@RequestParam String fieldName){
        return dictionaryService.getUserType(tableName,fieldName);
    }

    /**
     * 修改用户类型名称
     * @param typeName
     * @return
     */
    @GetMapping(value = "changeTypeName")
    public ResponseResult changeTypeName(@RequestParam int id,@RequestParam String typeName){
        return dictionaryService.changeTypeName(id,typeName);
    }

    /**
     * 修改字典表状态
     * @param id
     * @param status
     * @return
     */
    @GetMapping(value = "updateStatus")
    public ResponseResult updateStatus(@RequestParam int id,@RequestParam String status){
        return dictionaryService.updateStatus(id,status);
    }

    /**
     * 删除字典表的数据
     * @param id
     * @return
     */
    @DeleteMapping(value = "deleteData")
    public ResponseResult deleteData(@RequestParam int id){
        return dictionaryService.deleteData(id);
    }

    /**
     * 添加用户类型
     * @param typeName
     * @return
     */
    @GetMapping(value = "addUserType")
    public ResponseResult addUserType(@RequestParam String typeName){
        return dictionaryService.addUserType(typeName);
    }

}
